<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>登录</title>
  <link rel="shortcut icon" href="/static/super_cmdb/images/favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" media="screen" href="/static/super_cmdb/css/style.css">
  <link rel="stylesheet" type="text/css" href="/static/super_cmdb/css/reset.css"/>
</head>
<body>

<div id="particles-js">
		<div class="login">
			<div class="login-top">
				配置中心平台
			</div>
			<div class="login-center clearfix">
				<div class="login-center-img"><img src="/static/super_cmdb/images/name.png"/></div>
				<div class="login-center-input">
					<input type="text" id="username" name="" value="" placeholder="请输入您的用户名" onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的用户名'"/>
					<div class="login-center-input-text">用户名</div>
				</div>
			</div>
			<div class="login-center clearfix">
				<div class="login-center-img"><img src="/static/super_cmdb/images/password.png"/></div>
				<div class="login-center-input">
					<input type="password" id="password" name=""value="" placeholder="请输入您的密码" onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的密码'"/>
					<div class="login-center-input-text">密码</div>
				</div>
			</div>
			<div class="login-button" id="login_click" style="margin-left: 75px;">
				登陆
			</div>
		</div>
		<div class="sk-rotating-plane"></div>
</div>

<!-- scripts -->
<script src="/static/super_cmdb/js/particles.min.js"></script>
<script src="/static/super_cmdb/js/app.js"></script>
<script src="/static/super_cmdb/js/jquery.min.js"></script>
<script src="/static/super_cmdb/js/jquery.cookie.js"></script>
<script type="text/javascript">
     $(document).keydown(function(e){
         //实现回车触发点击按钮
        if (!e)
          e = window.event;
        if ((e.keyCode || e.which) == 13) {
          $("#login_click").click();
        }
     })

    $(function(){
    　　$("#login_click").click(function(){
            var username=$("#username").val();
            var password=$("#password").val();
            if (username == "") {
                alert("请输入用户名！");
                return false;
            }
            if (password == "") {
                alert("请输入密码！");
                return false;
            }
            $.ajax({
                    url: "/super_cmdb/login/",
                    type: "POST",
                    //data: $('#layui-form').serialize(),
                    data: {
                        "csrfmiddlewaretoken": '{{ csrf_token }}',
                        "username":username,
                        "password":password,
                        },
                    success: function (data) {
                        if(data.code == 1){
                            alert(data.msg);
                            return false;
                        }
                        else {
                            window.location.href="/super_cmdb/index/";
                            console.log("login success");
                        }
                    }
                });
    　　});
    })
</script>
</body>
</html>
